package com.zygh.lz.controller.pc;

import com.zygh.lz.entity.Account;
import com.zygh.lz.service.AccountService;
import com.zygh.lz.service.BrigadeRecordService;
import com.zygh.lz.stapprove.ResultUtil;
import com.zygh.lz.util.DataTime;
import com.zygh.lz.util.DateUtil;
import com.zygh.lz.util.DateUtils;
import com.zygh.lz.vo.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.security.Principal;
import java.text.ParseException;

/**
 * 大队档案统计
 *
 * @author wxh
 */
@Api(tags = "大队档案统计")
@RestController
@RequestMapping("/BrigadeRecordController")
public class BrigadeRecordController {
    @Resource
    private BrigadeRecordService brigadeRecordService;
    @Resource
    private AccountService accountService;

    @ApiOperation("获取总空岗数量")
    @GetMapping("getTotalVacantPost")
    public ResultBean getTotalVacantPost(@RequestParam Integer sectionId,
                                         @RequestParam String startTime,
                                         @RequestParam String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.getTotalVacantPost(sectionId, startTime, endTime));

    }

    @ApiOperation("获取签到统计")
    @GetMapping("getSignStatistics")
    public ResultBean getSignStatistics(@RequestParam Integer sectionId,
                                        @RequestParam String startTime,
                                        @RequestParam String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.getSignStatistics(sectionId, startTime, endTime));

    }

    @ApiOperation("获取大队排名")
    @GetMapping("getBrigadeRanking")
    public ResultBean getBrigadeRanking(@RequestParam Integer sectionId,
                                        @RequestParam String startTime,
                                        @RequestParam String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.getBrigadeRanking(sectionId, startTime, endTime));

    }


    @ApiOperation("岗位占比")
    @GetMapping("positionOf")
    public ResultBean positionOf(@RequestParam String sectionId) {
        return ResultUtil.setOK("success", brigadeRecordService.positionOf(sectionId));
    }


    @ApiOperation("接处警排名")
    @GetMapping("alertInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "人员id", dataType = "Integer", required = true),

    })
    public ResultBean alertInfo(@RequestParam Integer id) {
        return ResultUtil.setOK("success", brigadeRecordService.alertInfo(id));
    }


    @ApiOperation("调度")
    @GetMapping("informationInfo")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sectionId", value = "部门id", dataType = "Integer", required = true),

    })
    public ResultBean informationInfo(@RequestParam Integer sectionId) {
        return ResultUtil.setOK("success", brigadeRecordService.informationInfo(sectionId));
    }


    @ApiOperation("获取顶部信息")
    @GetMapping("getTopChange")
    public ResultBean getTopChange(@RequestParam Integer sectionId) {
        return ResultUtil.setOK("success", brigadeRecordService.getTopChange(sectionId));

    }

    @ApiOperation("效能考核")
    @GetMapping("efficiency")
    public ResultBean efficiency(@RequestParam Integer id) {
        return ResultUtil.setOK("success", brigadeRecordService.efficiency(id));

    }


    @ApiOperation("算分接口")
    @GetMapping("efficiencyData")
    public void efficiencyData(String startTime, String endTime) {
        brigadeRecordService.efficiencyData(startTime, endTime);
    }


    /**
     * ===================================大队档案第二版============================================
     */

    @ApiOperation("一周在线")
    @GetMapping("getSignWeek")
    public ResultBean getSignWeek(Integer sectionId,
                                  String startTime,
                                  String endTime) throws ParseException {
        return ResultUtil.setOK("success", brigadeRecordService.getSignWeek(sectionId, startTime, endTime));

    }

    @ApiOperation("一周巡逻里程(单位·米)")
    @GetMapping("getMileageAndSignTrend")
    public ResultBean getMileageAndSignTrend(Integer sectionId,
                                             String startTime,
                                             String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.getMileageAndSignTrend(sectionId, startTime, endTime));

    }

    @ApiOperation("一周巡查时长(单位·小时)")
    @GetMapping("getTotalPatrolDuration")
    public ResultBean getTotalPatrolDuration(Integer sectionId,
                                             String startTime,
                                             String endTime) throws ParseException {
        return ResultUtil.setOK("success", brigadeRecordService.getTotalPatrolDuration(sectionId, startTime, endTime));

    }

    @ApiOperation("今日接处警数量")
    @GetMapping("getPoliceData")
    public ResultBean getPoliceData(Integer sectionId,
                                    String startTime,
                                    String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.getPoliceData(sectionId, startTime, endTime));

    }


    @ApiOperation("今日接处警动态")
    @GetMapping("getJieChuJing")
    public ResultBean getJieChuJing(Integer sectionId,
                                    String startTime,
                                    String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.getJieChuJing(sectionId, startTime, endTime, 0));

    }


    @ApiOperation("一周接处警")
    @GetMapping("getWeekJieChuJing")
    public ResultBean getWeekJieChuJing(Integer sectionId,
                                        String startTime,
                                        String endTime) throws ParseException {
        return ResultUtil.setOK("success", brigadeRecordService.getWeekJieChuJing(sectionId, startTime, endTime));

    }

    @ApiOperation("一周执法总量")
    @GetMapping("getWeekillegallyPark")
    public ResultBean getWeekillegallyPark(Integer sectionId,
                                           String startTime,
                                           String endTime) throws ParseException {
        return ResultUtil.setOK("success", brigadeRecordService.getWeekillegallyPark(sectionId, startTime, endTime));

    }


    @ApiOperation("一周指挥调度")
    @GetMapping("getWeekInformation")
    public ResultBean getWeekInformation(Integer sectionId,
                                         String startTime,
                                         String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.getWeekInformation(sectionId, startTime, endTime));

    }


    @ApiOperation("今日执法数量")
    @GetMapping("illegalDataNum")
    public ResultBean illegalDataNum(Integer sectionId,
                                     String startTime,
                                     String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.illegalDataNum(sectionId, startTime, endTime));
    }

    @ApiOperation("今日执法动态")
    @GetMapping("illegalData")
    public ResultBean illegalData(Principal principal, Integer sectionId) {
        Account sysUser = accountService.getByUsername(principal.getName());

        return ResultUtil.setOK("success", brigadeRecordService.illegalData(sectionId, sysUser.getSysStaffId(), DateUtils.getDayBegin(), DateUtils.getDayEnd(), 0));
    }

    @ApiOperation("一周重点违法")
    @GetMapping("focusOnIllegal")
    public ResultBean focusOnIllegal(Integer sectionId,
                                     String startTime,
                                     String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.focusOnIllegal(sectionId, startTime, endTime));
    }

    @ApiOperation("一周信息上报")
    @GetMapping("InformationReported")
    public ResultBean InformationReported(Integer sectionId,
                                          String startTime,
                                          String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.InformationReported(sectionId, startTime, endTime));
    }

    @ApiOperation("一周信息上报分类")
    @GetMapping("problemReportedType")
    public ResultBean problemReportedType(Integer sectionId,
                                          String startTime,
                                          String endTime) {
        return ResultUtil.setOK("success", brigadeRecordService.problemReportedType(sectionId, startTime, endTime));
    }

    @ApiOperation("24小时各大队活跃度")
    @GetMapping("hourLiveness")
    public ResultBean hourLiveness(Integer sectionId) {
        return ResultUtil.setOK("success", brigadeRecordService.hourLiveness(sectionId));
    }


}
